<template>
  <div>
    <el-form ref="xForm" v-model="formData" :config="formConfig">
      <el-collapse   v-model="activeNames">
        <el-collapse-item name="1">
        <template #title>
          <el-icon class="header-icon">
            <info-filled />
          </el-icon>
          常规信息
        </template>
        <el-form-item label="节点Id" :rules="[{ required: true, message: 'Id 不能为空' }]">
          <el-input type="text" v-model="formData['id']" ></el-input>
        </el-form-item>
          <el-form-item label="节点名称" >
            <el-input  v-model="formData['name']" ></el-input>
          </el-form-item>
          <el-form-item label="节点描述" >
            <el-input type="textarea" v-model="formData['documentation']" ></el-input>
          </el-form-item>
      </el-collapse-item>
        <el-collapse-item name="2">
          <template #title>
            <el-icon class="header-icon">
              <List />
            </el-icon>
            执行监听器
          </template>
          <el-form-item label="监听器" >
            <FmSelectTable v-model:value="formData['executionListener']"  title="监听器" :columns="selectcolumns" url="/process/flowable" keys="formId"  lable="formName" tableName="sysform" >
            </FmSelectTable>
          </el-form-item>
        </el-collapse-item>
      </el-collapse>
    </el-form>
  </div>
</template>

<script>
import mixinPanel from '../../common/mixinPanel'
import mixinExecutionListener from '../../common/mixinExecutionListener'
import { commonParse } from '../../common/parseElement'
export default {
  mixins: [mixinPanel, mixinExecutionListener],
  data() {
    return {
      formData: {},
      activeNames:"1",
      selectcolumns:[
        {
          "label": "表单编号",//标签名称
          "index": "formId",//数据库索引
          "search": true,//是否是搜索表单
          "dataType": "text",//值值类型默认字符类型
          "addable":false
        },
        {
          "label": "表单名称",//标签名称
          "index": "formName",//数据库索引
          "search": true,//是否是搜索表单
          "dataType": "text",//值值类型默认字符类型
          "addable":false
        },
        {
          "label": "备注",//标签名称
          "index": "remark",//数据库索引
          "search": true,//是否是搜索表单
          "dataType": "text",//值值类型默认字符类型
          "addable":false
        },
      ],
    }
  },
  computed: {
    formConfig() {
      return {
        inline: false,
        item: [
          {
            xType: 'input',
            name: 'id',
            label: '节点 id',
            rules: [{ required: true, message: 'Id 不能为空' }]
          },
          {
            xType: 'input',
            name: 'name',
            label: '节点名称'
          },
          {
            xType: 'input',
            name: 'documentation',
            label: '节点描述'
          },
          {
            xType: 'slot',
            name: 'executionListener',
            label: '执行监听器'
          },
          {
            xType: 'switch',
            name: 'async',
            label: '异步',
            activeText: '是',
            inactiveText: '否'
          }
        ]
      }
    }
  },
  watch: {
    'formData.async': function(val) {
      if (val === '') val = null
      this.updateProperties({ 'flowable:async': val })
    }
  },
  created() {
    this.formData = commonParse(this.element)
  }
}
</script>

<style>

</style>
